/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(){
    $(".modal-trigger").click(function(a){
        a.preventDefault();
        
        var viewModal = "#" + $(this).attr('href');
        
        //get the center width of the browser
        var winW = $(window).width()/2;
        var modalW = $(viewModal).width()/2;
        var centerW = winW - modalW;
        
        //get the center height of the browser
        var winH = $(window).height()/2;
        var modalH = $(viewModal).height()/2;
        var centerH = winH - modalH;
        
        $(".modal-bg").fadeTo("fast", 0.8, function(){
           $(viewModal).fadeIn(500);
           $(viewModal).css("left", centerW);
           $(viewModal).css("bottom", centerH);
        });
    });
    
    $(".modal-bg").click(function(){
        $(".modal-bg, .modal-box").fadeOut("fast");
    });
});